home *** CD-ROM | disk | FTP | other *** search
- /*
- File: TestAppUtilities.c
-
- Contains: Sample code for Language Analysis Manager.
-
- Version: Technology: System 8
- Release: Daruma Developer Release 1
-
- Copyright: 1998 by Apple Computer, Inc., all rights reserved
-
- Contact: daruma@apple.com
-
- */
-
-
- #include "TestApp.h"
- #include "FunctionProto.h"
-
- #include <Windows.h>
- #include <TextUtils.h>
- #include <string.h>
- #include <Memory.h>
-
-
- // ========================================================================================
- // ShowErrorAlert
- // ========================================================================================
- void ShowErrorAlert ( OSStatus error )
- {
- Str31 errNumStr;
-
- if ( error == noErr) return;
-
- NumToString( error, errNumStr);
- ParamText( errNumStr, (unsigned char *)"", (unsigned char *)"", (unsigned char *)"");
-
- Alert( kErrorAlertResID, NULL);
- }
-
-
- // ========================================================================================
- // ShowCautionAlert
- // ========================================================================================
- void ShowCautionAlert ( void *msg1, void *msg2 )
- {
- ParamText( (StringPtr)msg1, (StringPtr)msg2, (StringPtr)"", (StringPtr)"");
-
- Alert( kCautionAlertResID, NULL);
- }
-
-
- // ========================================================================================
- // IsInputDialog
- // ========================================================================================
- Boolean IsInputDialog ( WindowRef window )
- {
- Str255 title;
-
- if ( window != NULL)
- {
- GetWTitle( window, title);
- return EqualString( title, "\pInput", true, true);
- }
-
- return false;
- }
-
-
- // ========================================================================================
- // GetDialogItemHandle
- // ========================================================================================
- Handle GetDialogItemHandle ( DialogRef dialog, short itemNo )
- {
- short itemType;
- Handle itemHandle;
- Rect box;
-
- GetDialogItem( dialog, itemNo, &itemType, &itemHandle, &box);
- return itemHandle;
- }
-
-
- // ========================================================================================
- // PascalStrToCStr
- // ========================================================================================
- char *PascalStrToCStr ( StringPtr pStr )
- {
- long len = (long)pStr[0];
-
- BlockMoveData( &pStr[1], &pStr[0], len);
- pStr[len] = '\0';
-
- return (char *)&pStr[0];
- }
-
-
- // ========================================================================================
- // CStrToPascalStr
- // ========================================================================================
- StringPtr CStrToPascalStr ( char *cStr )
- {
- long len = strlen( cStr);
-
- BlockMoveData( &cStr[0], &cStr[1], len);
- cStr[0] = len;
-
- return (StringPtr)&cStr[0];
- }
-
-
-
-
-